<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
// 现在有一个数组, 数组中的元素都是数字, 遍历每个元素,
// 然后把遍历到的质数存入到一个新的数组中
var arr = [10, 20, 22, 37, 47, 13, 17, 19, 29, 39];
var primes = [];
var other = []
for(var i = 0; i < arr.length; i++){
    if(isPrime(arr[i])){
        primes[primes.length] = arr[i];
    }else{
        other[other.length] = arr[i]
    }
}
console.log(primes);
console.log(other);
function isPrime(num){
    for (var i = 2; i < num; i++){
        if (num % i == 0){
            return false;
        }
    }
    return true;
}

</script>
</body>
</html>